home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 1999 May / SGI IRIX 6.5 Applications 1999 May.iso / dist / nss_fasttrack.idb / var / netscape / fasttrack / include / nsacl / acldef.h.z / acldef.h
C/C++ Source or Header  |  1998-10-13  |  13KB  |  471 lines

  1. /*
  2.    PROPRIETARY SOURCE CODE OF NETSCAPE COMMUNICATIONS CORPORATION.
  3.  
  4.    Copyright (c) 1996 and 1997 Netscape Communications Corporation.
  5.    All rights reserved.
  6.  
  7.    Use of this Source Code is subject to the terms of the applicable
  8.    license agreement from Netscape Communications Corporation.
  9. */
  10.  
  11. #ifndef PUBLIC_NSACL_ACLDEF_H
  12. #define PUBLIC_NSACL_ACLDEF_H
  13.  
  14. /*
  15.  * File:        acldef.h
  16.  *
  17.  * Description:
  18.  *
  19.  *      This file contains constant and type definitions for the ACL API.
  20.  */
  21.  
  22. #ifndef PUBLIC_NSACL_NSERRDEF_H
  23. #include "nserrdef.h"
  24. #endif /* !PUBLIC_NSACL_NSERRDEF_H */
  25.  
  26. #ifndef PUBLIC_NSACL_PLISTDEF_H
  27. #include "plistdef.h"
  28. #endif /* !PUBLIC_NSACL_PLISTDEF_H */
  29.  
  30. NSPR_BEGIN_EXTERN_C
  31.  
  32. /*
  33.  * Type:        ACLCachable_t
  34.  *
  35.  * Description:
  36.  *
  37.  *      This type is used to specify whether and how long something
  38.  *      may be safely cached.  A value of zero (ACL_NOT_CACHABLE)
  39.  *      indicates that the item is not cachable.  Any other value is
  40.  *      a time, in seconds since 00:00:00 UTC, January 1, 1970, after
  41.  *      which the cached information should be discarded.
  42.  */
  43.  
  44. typedef unsigned long ACLCachable_t;
  45.  
  46. #define ACL_NOT_CACHABLE        0
  47. #define ACL_INDEF_CACHABLE      ((unsigned long)(-1))
  48.  
  49. /*
  50.  * Type:        ACLListHandle_t
  51.  *
  52.  * Description:
  53.  *
  54.  *      This type represents a list of ACLs in their in-memory form.
  55.  */
  56.  
  57. typedef struct ACLListHandle ACLListHandle_t;
  58.  
  59. /* The object has been checked for ACLs and has none attached */
  60. #define    ACL_LIST_NO_ACLS    ((ACLListHandle_t *)-1)
  61.  
  62. /*
  63.  * Type:        ACLHandle_t
  64.  *
  65.  * Description:
  66.  *
  67.  *      This type represents the in-memory form of an ACL.
  68.  */
  69.  
  70. typedef struct ACLHandle ACLHandle_t;
  71.  
  72. /*
  73.  * Type:        ACLListEnum_t
  74.  *
  75.  * Description:
  76.  *
  77.  *      This type contains the state of an ACL list enumeration.
  78.  */
  79.  
  80. typedef void *ACLListEnum_t;
  81.  
  82. /*
  83.  * Type:        ACLExprHandle_t
  84.  *
  85.  * Description:
  86.  *
  87.  *      This type represents a single ACL entry, e.g. allow, deny, etc.
  88.  */
  89.  
  90. typedef struct ACLExprHandle ACLExprHandle_t;
  91.  
  92. /*
  93.  * Type:        ACLEvalHandle_t
  94.  *
  95.  * Description:
  96.  *
  97.  *      This type represents an ACL evaluation context, which includes
  98.  *      an ACL list and property lists for the subject and resource.
  99.  */
  100.  
  101. typedef struct ACLEvalHandle ACLEvalHandle_t;
  102.  
  103. /*
  104.  * Type:        PFlags_t
  105.  *
  106.  * Description:
  107.  *
  108.  *      This type represents a set of processing flags for an ACL entry.
  109.  */
  110. typedef int PFlags_t;
  111.  
  112. #define ACL_PFLAG_ABSOLUTE      0x1
  113. #define ACL_PFLAG_TERMINAL      0x2
  114. #define ACL_PFLAG_CONTENT      0x4
  115.  
  116. #define IS_ABSOLUTE(x)        ((x) & ACL_PFLAG_ABSOLUTE)
  117. #define IS_STATIC(x)        ((x) & ACL_PFLAG_STATIC)
  118. #define IS_CONTENT(x)        ((x) & ACL_PFLAG_CONTENT)
  119.  
  120. /*
  121.  * Type:        CmpOp_t
  122.  *
  123.  * Description:
  124.  *
  125.  *      This type represents a comparison operator in an ACL attribute
  126.  *      expression.
  127.  */
  128. typedef enum    {
  129.         CMP_OP_EQ,
  130.         CMP_OP_NE,
  131.         CMP_OP_GT,
  132.         CMP_OP_LT,
  133.         CMP_OP_GE,
  134.         CMP_OP_LE
  135.         } CmpOp_t;
  136.  
  137. /*
  138.  * Type:        ACLExprType_t
  139.  *
  140.  * Description:
  141.  *
  142.  *      This type represents the type of an ACL entry.
  143.  */
  144. typedef enum     {
  145.         ACL_EXPR_TYPE_ALLOW,
  146.         ACL_EXPR_TYPE_DENY,
  147.         ACL_EXPR_TYPE_AUTH,
  148.         ACL_EXPR_TYPE_RESPONSE
  149.         } ACLExprType_t;
  150.  
  151. /*
  152.  * Type:        ACLEvalRes_t
  153.  *
  154.  * Description:
  155.  *
  156.  *      This type represents the result of ACL evaluation.
  157.  */
  158. typedef enum    {
  159.         ACL_RES_ALLOW,
  160.         ACL_RES_DENY,
  161.         ACL_RES_FAIL,
  162.         ACL_RES_INVALID,
  163.         ACL_RES_NONE
  164.         } ACLEvalRes_t;
  165.  
  166. /*
  167.  * Type:        ACLMethod_t
  168.  *
  169.  * Description:
  170.  *
  171.  *      This type represents a reference to an authentication method.
  172.  */
  173. typedef    void * ACLMethod_t;
  174.  
  175. #define    ACL_METHOD_ANY        ((ACLMethod_t)-1)
  176. #define    ACL_METHOD_INVALID    ((ACLMethod_t)-2)
  177.  
  178. /*
  179.  * Type:        ACLDbType_t
  180.  *
  181.  * Description:
  182.  *
  183.  *      This type represents a reference to a type of authentication
  184.  *      database.
  185.  */
  186. typedef    void * ACLDbType_t;
  187.  
  188. #define    ACL_DBTYPE_ANY        ((ACLDbType_t)-1)
  189. #define    ACL_DBTYPE_INVALID    ((ACLDbType_t)-2)
  190.  
  191. /*
  192.  * Type:        ACLAttrGetterFn_t
  193.  *
  194.  * Description:
  195.  *
  196.  *      This type describes a kind of callback function that obtains
  197.  *      a value for an ACL attribute and enters the attribute and value
  198.  *      into the subject property list.
  199.  */
  200. typedef int (*ACLAttrGetterFn_t)(NSErr_t *errp, PList_t subject,
  201.                                  PList_t resource, PList_t auth_info,
  202.                                  PList_t global_auth, void *arg);
  203.  
  204. typedef struct ACLAttrGetter ACLAttrGetter_t;
  205. typedef void *ACLAttrGetterList_t;
  206.  
  207. /*
  208.  * Type:        AclModuleInitFunc
  209.  *
  210.  * Description:
  211.  *
  212.  *      This type describes a kind of callback function that is
  213.  *      specified to ACL_ModuleRegister() and called from there.
  214.  *    The function should return 0 on success and non-zero on
  215.  *    failure.
  216.  */
  217. typedef int (*AclModuleInitFunc)(NSErr_t *errp);
  218.  
  219. /*
  220.  * Type:        DbParseFn_t
  221.  *
  222.  * Description:
  223.  *
  224.  *      This type describes a kind of callback function that parses
  225.  *      a reference to an authentication database of a particular
  226.  *      database type.  It is called when ACL_DatabaseRegister() is
  227.  *      called for a database which is that database type.
  228.  *    The function should return 0 on success and non-zero on
  229.  *    failure.
  230.  */
  231. typedef int (*DbParseFn_t)(NSErr_t *errp, ACLDbType_t dbtype,
  232.                const char *name, const char *url,
  233.                PList_t plist, void **db);
  234.  
  235. /*
  236.  * Type:        AclCacheFlushFunc_t
  237.  *
  238.  * Description:
  239.  *
  240.  *      This type describes a kind of callback function that is called
  241.  *      when ACL_CacheFlush() is called.
  242.  */
  243. typedef int (*AclCacheFlushFunc_t)(void);
  244.  
  245. /*
  246.  * Type:        LASEvalFunc_t
  247.  *
  248.  * Description:
  249.  *
  250.  *      This type describes a kind of callback function that is called
  251.  *      to evaluate an attribute value expression in an ACL statement.
  252.  */
  253. typedef int (*LASEvalFunc_t)(NSErr_t *errp, char *attr_name,
  254.                              CmpOp_t comparator, char *attr_pattern,
  255.                              ACLCachable_t *cachable, void **cookie,
  256.                              PList_t subject, PList_t resource,
  257.                              PList_t auth_info, PList_t global_auth);
  258.  
  259. /*
  260.  * Type:        LASFlushFunc_t
  261.  *
  262.  * Description:
  263.  *
  264.  *      This type describes a kind of callback function that is called
  265.  *      when a previously cached LAS cookie is being flushed from
  266.  *      the ACL cache.
  267.  */
  268. typedef void (*LASFlushFunc_t)(void **cookie);
  269.  
  270. /*
  271.  * Type:        LDAP
  272.  *
  273.  * Description:
  274.  *
  275.  *      This is an opaque type that represents an open LDAP connection.
  276.  *      It is used mostly via the LDAP SDK API.
  277.  *    Include the <ldap.h> file before including this file if you wish to
  278.  *    use the function ACL_LDAPDatabaseHandle.
  279.  */
  280. #ifndef _LDAP_H
  281. typedef struct ldap LDAP;
  282. #endif /* _LDAP_H */
  283.  
  284.  
  285. /*  Flags to ACL_ListFind  */
  286. #define ACL_CASE_INSENSITIVE     0x1
  287. #define ACL_CASE_SENSITIVE     0x2
  288.  
  289. #define    ACL_MAX_TEST_RIGHTS    32
  290. #define    ACL_MAX_GENERIC        32
  291.  
  292. /*
  293.  * ACLERRFAIL -- Use this as an 'retcode' argument to nserrGenerate.
  294.  */
  295. #define ACLERRFAIL    -11
  296.  
  297.  
  298. /*
  299.  *    Command values for the "position" argument to ACL_RegisterGetter
  300.  *    Any positive >0 value is the specific position in the list to insert
  301.  *    the new function.
  302.  */
  303. #define    ACL_AT_FRONT        0
  304. #define    ACL_AT_END        -1
  305. #define    ACL_REPLACE_ALL     -2
  306. #define    ACL_REPLACE_MATCHING    -3
  307.  
  308. #define ACL_ATTR_GROUP          "group"
  309. #define ACL_ATTR_GROUP_INDEX        1
  310. #define ACL_ATTR_RAW_USER_LOGIN "user-login"
  311. #define ACL_ATTR_RAW_USER_LOGIN_INDEX    2
  312. #define ACL_ATTR_AUTH_USER    "auth-user"
  313. #define ACL_ATTR_AUTH_USER_INDEX    3
  314. #define ACL_ATTR_AUTH_TYPE    "auth-type"
  315. #define ACL_ATTR_AUTH_TYPE_INDEX    4
  316. #define ACL_ATTR_AUTH_DB    "auth-db"
  317. #define ACL_ATTR_AUTH_DB_INDEX        5
  318. #define ACL_ATTR_AUTH_PASSWORD  "auth-password"
  319. #define ACL_ATTR_AUTH_PASSWORD_INDEX    6
  320. #define ACL_ATTR_USER            "user"
  321. #define ACL_ATTR_USER_INDEX        7
  322. #define ACL_ATTR_PASSWORD    "pw"
  323. #define ACL_ATTR_PASSWORD_INDEX        8
  324. #define ACL_ATTR_USERDN            "userdn"
  325. #define ACL_ATTR_USERDN_INDEX        9
  326. #define ACL_ATTR_RAW_USER    "raw-user"
  327. #define ACL_ATTR_RAW_USER_INDEX        10
  328. #define ACL_ATTR_RAW_PASSWORD   "raw-pw"
  329. #define ACL_ATTR_RAW_PASSWORD_INDEX    11
  330. #define ACL_ATTR_USER_ISMEMBER  "user-ismember"
  331. #define ACL_ATTR_USER_ISMEMBER_INDEX    12
  332. #define ACL_ATTR_DATABASE    "database"
  333. #define ACL_ATTR_DATABASE_INDEX        13
  334. #define ACL_ATTR_DBTYPE            "dbtype"
  335. #define ACL_ATTR_DBTYPE_INDEX        14
  336. #define ACL_ATTR_DBNAME            "dbname"
  337. #define ACL_ATTR_DBNAME_INDEX        15
  338. #define ACL_ATTR_DATABASE_URL   "url"
  339. #define ACL_ATTR_DATABASE_URL_INDEX    16
  340. #define ACL_ATTR_METHOD            "method"
  341. #define ACL_ATTR_METHOD_INDEX        17
  342. #define ACL_ATTR_AUTHTYPE    "authtype"
  343. #define ACL_ATTR_AUTHTYPE_INDEX        18
  344. #define ACL_ATTR_AUTHORIZATION  "authorization"
  345. #define ACL_ATTR_AUTHORIZATION_INDEX    19
  346. #define ACL_ATTR_PARSEFN    "parsefn"
  347. #define ACL_ATTR_PARSEFN_INDEX        20
  348. #define ACL_ATTR_ATTRIBUTE    "attr"
  349. #define ACL_ATTR_ATTRIBUTE_INDEX    21
  350. #define ACL_ATTR_GETTERFN    "getterfunc"
  351. #define ACL_ATTR_GETTERFN_INDEX        22
  352. #define ACL_ATTR_IP        "ip"
  353. #define ACL_ATTR_IP_INDEX        23
  354. #define ACL_ATTR_DNS            "dns"
  355. #define ACL_ATTR_DNS_INDEX        24
  356. #define ACL_ATTR_MODULE            "module"
  357. #define ACL_ATTR_MODULE_INDEX        25
  358. #define ACL_ATTR_MODULEFUNC    "func"
  359. #define ACL_ATTR_MODULEFUNC_INDEX    26
  360. #define ACL_ATTR_GROUPS            "groups"
  361. #define ACL_ATTR_GROUPS_INDEX        27
  362. #define ACL_ATTR_IS_VALID_PASSWORD "isvalid-password"
  363. #define ACL_ATTR_IS_VALID_PASSWORD_INDEX    28
  364. #define ACL_ATTR_CERT2USER    "cert2user"
  365. #define ACL_ATTR_CERT2USER_INDEX    29
  366. #define ACL_ATTR_USER_CERT    "cert"
  367. #define ACL_ATTR_USER_CERT_INDEX    30
  368. #define ACL_ATTR_PROMPT            "prompt"
  369. #define ACL_ATTR_PROMPT_INDEX        31
  370. #define ACL_ATTR_TIME            "time"
  371. #define ACL_ATTR_TIME_INDEX        32
  372. #define ACL_ATTR_USERS_GROUP    "users-group"
  373. #define ACL_ATTR_USERS_GROUP_INDEX    33
  374. #define    ACL_ATTR_SESSION        "session"       /* subject property */
  375. #define ACL_ATTR_SESSION_INDEX        34
  376. #define    ACL_ATTR_REQUEST        "request"       /* resource property */
  377. #define ACL_ATTR_REQUEST_INDEX        35
  378. #define ACL_ATTR_ERROR        "error"
  379. #define    ACL_ATTR_ERROR_INDEX        36
  380. #define ACL_ATTR_PROGRAMS        "programs"      /* resource property */
  381. #define    ACL_ATTR_PROGRAMS_INDEX        37
  382. #define ACL_ATTR_ACCEL_AUTH        "accel-authorization"
  383. #define ACL_ATTR_ACCEL_AUTH_INDEX    38
  384. #define ACL_ATTR_WWW_AUTH_PROMPT    "www-auth-prompt"
  385. #define ACL_ATTR_WWW_AUTH_PROMPT_INDEX    39
  386. #define ACL_ATTR_OWNER            "owner"
  387. #define ACL_ATTR_OWNER_INDEX        40
  388. #define ACL_ATTR_IS_OWNER        "is-owner"
  389. #define ACL_ATTR_IS_OWNER_INDEX        41
  390. #define ACL_ATTR_CACHED_USER        "cached-user"
  391. #define ACL_ATTR_CACHED_USER_INDEX    42
  392. #define ACL_ATTR_USER_EXISTS        "user-exists"
  393. #define ACL_ATTR_USER_EXISTS_INDEX    43
  394.  
  395. /*    Must be 1 larger than the highest index used    */
  396. #define    ACL_ATTR_INDEX_MAX        44
  397.  
  398. #ifdef    ALLOCATE_ATTR_TABLE
  399. /* Must be in the same order as the index numbers */
  400. char    *ACLAttrTable[] = {
  401.          NULL,                /*  0 */
  402. /* Don't have one numbered 0 */
  403.          ACL_ATTR_GROUP,        /*  1 */
  404.          ACL_ATTR_RAW_USER_LOGIN,    /*  2 */
  405.          ACL_ATTR_AUTH_USER,        /*  3 */
  406.          ACL_ATTR_AUTH_TYPE,        /*  4 */
  407.          ACL_ATTR_AUTH_DB,        /*  5 */
  408.          ACL_ATTR_AUTH_PASSWORD,    /*  6 */
  409.          ACL_ATTR_USER,            /*  7 */
  410.          ACL_ATTR_PASSWORD,        /*  8 */
  411.          ACL_ATTR_USERDN,        /*  9 */
  412.          ACL_ATTR_RAW_USER,        /* 10 */
  413.          ACL_ATTR_RAW_PASSWORD,        /* 11 */
  414.          ACL_ATTR_USER_ISMEMBER,    /* 12 */
  415.          ACL_ATTR_DATABASE,        /* 13 */
  416.          ACL_ATTR_DBTYPE,        /* 14 */
  417.          ACL_ATTR_DBNAME,        /* 15 */
  418.          ACL_ATTR_DATABASE_URL,        /* 16 */
  419.          ACL_ATTR_METHOD,        /* 17 */
  420.          ACL_ATTR_AUTHTYPE,        /* 18 */
  421.          ACL_ATTR_AUTHORIZATION,    /* 19 */
  422.          ACL_ATTR_PARSEFN,        /* 20 */
  423.          ACL_ATTR_ATTRIBUTE,        /* 21 */
  424.          ACL_ATTR_GETTERFN,        /* 22 */
  425.          ACL_ATTR_IP,            /* 23 */
  426.          ACL_ATTR_DNS,            /* 24 */
  427.          ACL_ATTR_MODULE,        /* 25 */
  428.          ACL_ATTR_MODULEFUNC,        /* 26 */
  429.          ACL_ATTR_GROUPS,        /* 27 */
  430.          ACL_ATTR_IS_VALID_PASSWORD,    /* 28 */
  431.          ACL_ATTR_CERT2USER,        /* 29 */
  432.          ACL_ATTR_USER_CERT,        /* 30 */
  433.          ACL_ATTR_PROMPT,        /* 31 */
  434.          ACL_ATTR_TIME,            /* 32 */
  435.          ACL_ATTR_USERS_GROUP,        /* 33 */
  436.          ACL_ATTR_SESSION,        /* 34 */
  437.          ACL_ATTR_REQUEST,        /* 35 */
  438.          ACL_ATTR_ERROR,        /* 36 */
  439.          ACL_ATTR_PROGRAMS,        /* 37 */
  440.          ACL_ATTR_ACCEL_AUTH,        /* 38 */
  441.          ACL_ATTR_WWW_AUTH_PROMPT,    /* 39 */
  442.          ACL_ATTR_OWNER,        /* 40 */
  443.          ACL_ATTR_IS_OWNER,        /* 41 */
  444.          ACL_ATTR_CACHED_USER,        /* 42 */
  445.          ACL_ATTR_USER_EXISTS        /* 43 */
  446. };
  447. #endif
  448.  
  449.  
  450. #define ACL_DBTYPE_LDAP         "ldap"
  451.  
  452. #define METHOD_DEFAULT          "default"
  453.  
  454. /*  Errors must be < 0 */
  455. #define ACL_RES_ERROR          -1
  456.  
  457. /* LAS return codes - Must all be negative numbers */
  458. #define    LAS_EVAL_TRUE        -1
  459. #define    LAS_EVAL_FALSE        -2
  460. #define    LAS_EVAL_DECLINE    -3
  461. #define    LAS_EVAL_FAIL        -4
  462. #define    LAS_EVAL_INVALID    -5
  463. #define    LAS_EVAL_NEED_MORE_INFO    -6
  464.  
  465. /* Max pathlength.  Intended to match REQ_MAX_LEN */
  466. #define ACL_PATH_MAX    4096
  467.  
  468. NSPR_END_EXTERN_C
  469.  
  470. #endif /* !PUBLIC_NSACL_ACLDEF_H */
  471.